<%#
 Copyright 2013-2025 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      https://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
package <%= packageName %>.domain;

<%_ if (databaseTypeCouchbase) { _%>
import org.springframework.data.couchbase.core.mapping.Field;
<%_ } _%>
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
<%_ if (!reactive) { _%>
import org.springframework.data.annotation.CreatedBy;
<%_ } _%>
import org.springframework.data.annotation.CreatedDate;
<%_ if (!reactive) { _%>
import org.springframework.data.annotation.LastModifiedBy;
<%_ } _%>
import org.springframework.data.annotation.LastModifiedDate;
<%_ if (databaseTypeMongodb) { _%>
import org.springframework.data.mongodb.core.mapping.Field;
<%_ } _%>
<%_ if (databaseTypeNeo4j) { _%>
import org.springframework.data.neo4j.core.schema.Property;
<%_ } _%>
<%_ if (databaseTypeSql && !reactive) { _%>
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
<%_ } _%>

import java.io.Serial;
import java.io.Serializable;
import java.time.Instant;
<%_ if (databaseTypeSql) { _%>
import jakarta.persistence.Column;
<%_ } _%>
<%_ if (databaseTypeSql && !reactive) { _%>
import jakarta.persistence.EntityListeners;
import jakarta.persistence.MappedSuperclass;
<%_ } _%>

/**
 * Base abstract class for entities which will hold definitions for created, last modified, created by,
 * last modified by attributes.
 */
<%_ if (databaseTypeSql && !reactive) { _%>
@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
<%_ } _%>
@JsonIgnoreProperties(value = { "createdBy", "createdDate", "lastModifiedBy", "lastModifiedDate" }, allowGetters = true)
public abstract class AbstractAuditingEntity<T> implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    public abstract T getId();

<%_ if (!reactive) { _%>
    @CreatedBy
<%_ } _%>
<%_ if (databaseTypeSql) { _%>
    @Column(name = "created_by", nullable = false, length = 50, updatable = false)
<%_ } _%>
<%_ if (databaseTypeMongodb) { _%>
    @Field("created_by")
<%_ } _%>
<%_ if (databaseTypeCouchbase) { _%>
    @Field
<%_ } _%>
<%_ if (databaseTypeNeo4j) { _%>
    @Property("created_by")
<%_ } _%>
    private String createdBy;

    @CreatedDate
<%_ if (databaseTypeSql) { _%>
    @Column(name = "created_date", updatable = false)
<%_ } _%>
<%_ if (databaseTypeMongodb) { _%>
    @Field("created_date")
<%_ } _%>
<%_ if (databaseTypeCouchbase) { _%>
    @Field
<%_ } _%>
<%_ if (databaseTypeNeo4j) { _%>
    @Property("created_date")
<%_ } _%>
    private Instant createdDate = Instant.now();

<%_ if (!reactive) { _%>
    @LastModifiedBy
<%_ } _%>
<%_ if (databaseTypeSql) { _%>
    @Column(name = "last_modified_by", length = 50)
<%_ } _%>
<%_ if (databaseTypeMongodb) { _%>
    @Field("last_modified_by")
<%_ } _%>
<%_ if (databaseTypeCouchbase) { _%>
    @Field
<%_ } _%>
<%_ if (databaseTypeNeo4j) { _%>
    @Property("last_modified_by")
<%_ } _%>
    private String lastModifiedBy;

    @LastModifiedDate
<%_ if (databaseTypeSql) { _%>
    @Column(name = "last_modified_date")
<%_ } _%>
<%_ if (databaseTypeMongodb) { _%>
    @Field("last_modified_date")
<%_ } _%>
<%_ if (databaseTypeCouchbase) { _%>
    @Field
<%_ } _%>
<%_ if (databaseTypeNeo4j) { _%>
    @Property("last_modified_date")
<%_ } _%>
    private Instant lastModifiedDate = Instant.now();

    public String getCreatedBy() {
        return createdBy;
    }

    public void setCreatedBy(String createdBy) {
        this.createdBy = createdBy;
    }

    public Instant getCreatedDate() {
        return createdDate;
    }

    public void setCreatedDate(Instant createdDate) {
        this.createdDate = createdDate;
    }

    public String getLastModifiedBy() {
        return lastModifiedBy;
    }

    public void setLastModifiedBy(String lastModifiedBy) {
        this.lastModifiedBy = lastModifiedBy;
    }

    public Instant getLastModifiedDate() {
        return lastModifiedDate;
    }

    public void setLastModifiedDate(Instant lastModifiedDate) {
        this.lastModifiedDate = lastModifiedDate;
    }
}
